<template>
    <div>
        <h1>科室列表</h1>
        <div>
            科室名称:<input type="text" v-model="lists.DName">
            <input type="button" value="查询" class="btn btn-primary" @click="getdata">
        </div>
        <table class="table table-bordered">
            <tbody>
                <tr>
                    <th>科室名称</th>
                    <th>科室图片</th>
                    <th>成立时间</th>
                </tr>
                <tr v-for="item in list"> 
                    <th>{{ item.DName }}</th>
                    <th><img :src="item.DPhoto" width="100" height="100"></th>
                    <th>{{ moment( item.CreateTime).format( "YYYY-MM-DD") }}</th>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import { ref,reactive,onMounted } from 'vue';
import axios from 'axios';
import moment from 'moment';
import { useRoute,useRouter } from 'vue-router';
const route = useRoute()
const router = useRouter()

let lists:any=reactive({
    DName:""
})
let list:any = ref([])

onMounted(()=>{
    getdata() 
})

const getdata=()=>{
    axios({
        url:'/api/Depart/GetDepartment',
        method:'get',
        params:lists
    })
    .then((res)=>{
        console.log(res);
        list.value=res.data
    })
}

</script>

<style scoped>
input{
    margin: 0 10px;
}
</style>